import request from '@/axios'
import type { CurdData } from './types'

export const getListApi = (params: any) => {
  return request.get({ url: '/admin/purchase', params })
}

export const delListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.delete({ url: '/admin/purchase', data: { ids } })
}

export const getInfoApi = (id: string): Promise<IResponse> => {
  return request.get({ url: '/admin/purchase/' + id })
}

export const saveDataApi = (data: Partial<CurdData>): Promise<IResponse> => {
  if (data.id) {
    return request.put({ url: '/admin/purchase', data })
  } else {
    return request.post({ url: '/admin/purchase', data })
  }
}

export const getBrandListApi = (params: any) => {
  return request.get({ url: '/admin/purchase/select', params })
}

export const getFieldEnumApi = (params: any) => {
  return request.get({ url: '/admin/purchase/fieldEnum', params })
}

export const examineApi = (data): Promise<IResponse> => {
  return request.post({ url: '/admin/purchase/examine', data })
}

export const confirmApi = (data): Promise<IResponse> => {
  return request.post({ url: '/admin/purchase/confirm', data })
}

export const entryApi = (data): Promise<IResponse> => {
  return request.post({ url: '/admin/purchase/entry', data })
}

export const batchEntryApi = (data): Promise<IResponse> => {
  return request.post({ url: '/admin/purchase/batchEntry', data })
}

//获取物流费用
export const getLogisticsInfoApi = (params): Promise<IResponse> => {
  return request.get({ url: '/admin/purchaseLogistics', params })
}
//新增物流费用
export const createLogisticsCostsApi = (data): Promise<IResponse> => {
  return request.post({ url: '/admin/purchaseLogistics', data })
}
//更新物流费用
export const editLogisticsCostsApi = (id: string | number, data): Promise<IResponse> => {
  return request.put({ url: `/admin/purchaseLogistics/${id}`, data })
}
//删除物流费用
export const delLogisticsCostsApi = (id: string | number, data): Promise<IResponse> => {
  return request.delete({ url: `/admin/purchaseLogistics/${id}`, data })
}

export const getOrderSelectApi = (params: any) => {
  return request.get({ url: '/admin/purchase/salesOrderNo', params })
}

export const getProductSelectApi = (params: any) => {
  return request.get({ url: '/admin/purchase/orderProduct', params })
}

export const redInkReversalApi = (data): Promise<IResponse> => {
  return request.post({ url: '/admin/purchase/redInkReversal', data })
}
